<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion2.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
		date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
		$usuario = $_SESSION['name'];
		$fecha = date("Y-m-d H:i:s");
		$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Registro estudiante regular liceo' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}
include("conexion.php");

//alumno
$cedula=$_GET['cedula'];

if($cedula){
	if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; $periodo="$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; $periodo="$anio - $anio2"; }

	$existe=mysql_fetch_row(mysql_query("SELECT * FROM alumno WHERE CI_a='$cedula' "));
		if($existe > 0){
			$sql=mysql_query("SELECT inscripcion.periodo, alumno.CI_a, alumno.nombre_a, alumno.apellido_a, alumno.lugar_n_a, alumno.fecha_n_a, inscripcion.repite, inscripcion.grado, inscripcion.seccion FROM alumno INNER JOIN inscripcion ON alumno.CI_a=inscripcion.cedula_a WHERE inscripcion.periodo='$periodo' AND inscripcion.cedula_a='$cedula' order by grado desc ");
			$row=mysql_fetch_row($sql);

			//fecha actual
			$dia=date(j);
			$mes=date(n);
			$ano=date(Y);

			list($f_nac_dia,$f_nac_mes,$f_nac_ano) = explode("-",$row[5]);
				 
			//si el mes es el mismo pero el día inferior aun no ha cumplido años, le quitaremos un año al actual
			if (($f_nac_mes == $mes) && ($f_nac_dia > $dia)) {
			$ano=($ano-1); }
			 
			//si el mes es superior al actual tampoco habrá cumplido años, por eso le quitamos un año al actual
			if ($f_nac_mes > $mes) {
			$ano=($ano-1);}
			 
			//ya no habría mas condiciones, ahora simplemente restamos los años y mostramos el resultado como su edad
			$edad_a=($ano-$f_nac_ano);

			//representante
			$sql_r=mysql_query("select * from grupo_familiar where CI_gf=(select Grupo_familiar_CI_gf from grupo_familiar_has_alumno where Alumno_CI_a='$cedula') ");
			$row_r=mysql_fetch_row($sql_r);
			$mat_pend=mysql_fetch_array(mysql_query("select nombre_m, ano_m from materia inner join inscripcion on cod_m=mat_pend_1 where cedula_a='$cedula' and periodo = '$periodo' order by grado desc limit 1"));
			$mat_pend2=mysql_fetch_array(mysql_query("select nombre_m, ano_m from materia inner join inscripcion on cod_m=mat_pend_2 where cedula_a='$cedula' and periodo = '$periodo' order by grado desc limit 1"));
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Estudiante Regular</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="js/ValidarEstReg.js" type="text/javascript"></script>
<script src="js/prototype.js" type="text/javascript"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
Validar();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

function materias(mat){ 
	if (mat=="1er"){
	document.getElementById('materias_s').style.display="inline";
	document.getElementById('materias_o').style.display="none";
	document.getElementById('materias_n').style.display="none";
	}else if (mat=="2do"){
	document.getElementById('materias_o').style.display="inline";
	document.getElementById('materias_s').style.display="none";
	document.getElementById('materias_n').style.display="none";
	}else if (mat=="3er"){
	document.getElementById('materias_n').style.display="inline";
	document.getElementById('materias_s').style.display="none";
	document.getElementById('materias_o').style.display="none";
	}else if (mat==""){
	document.getElementById('materias_s').style.display="none";
	document.getElementById('materias_o').style.display="none";
	document.getElementById('materias_n').style.display="none";
	}
}

function comprobar_a()
{  
  var url = 'http://127.0.0.1/sistema/sistema_liceo/comprobar_a.php';
  var pars= ('cedula=' + document.getElementById('cedula').value);
  var myAjax = new Ajax.Updater( 'comprobar_mensaje_a', url, { method: 'get', parameters: pars});
}

//seleccionar o deseleccionar checkbox
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Desmarcar todos"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Marcar todos"; }
}

function DeshabilitaSelect()
{
	if (document.getElementById("fotos_r").checked) {
		document.getElementById("fot_r").disabled = false;
	} else {
		document.getElementById("fot_r").disabled = true;
	}if (document.getElementById("fotos_a").checked) {
		document.getElementById("fot_a").disabled = false;
	} else {
		document.getElementById("fot_a").disabled = true;
	}
}

function SeleccionarMaterias(mat) {
	var o;
	document.forms.alumno_re.grado_mat_pend.disabled = true;
		<?php $materias = mysql_query("SELECT * FROM materia");
				while($mat = mysql_fetch_array($materias)) { ?>
	if(mat == "<?php echo $mat[2]; ?>") {
		o = document.createElement("OPTION");
		o.text="<?php echo $mat[1]; ?>";
		o.value="<?php echo $mat[0]; ?>";
		document.forms.alumno_re.materia_pend.options.add(o);
	}
<?php } ?>
			document.forms.alumno_re.materia_pend.disabled = false;
	}
function ComponerMaterias(mat) {
	document.forms.alumno_re.grado_mat_pend.disabled = true;
		for(var i=document.forms.alumno_re.materia_pend.options.length-1; i>0; i--){
			document.forms.alumno_re.materia_pend.remove(i);
		}
	SeleccionarMaterias(mat);
	document.forms.alumno_re.grado_mat_pend.disabled = false;
}

function SeleccionarMaterias2(mat) {
	var o;
	document.forms.alumno_re.grado_mat_pend2.disabled = true;
		<?php $materias = mysql_query("SELECT * FROM materia");
				while($mat = mysql_fetch_array($materias)) { ?>
	if(mat == "<?php echo $mat[2]; ?>") {
		o = document.createElement("OPTION");
		o.text="<?php echo $mat[1]; ?>";
		o.value="<?php echo $mat[0]; ?>";
		document.forms.alumno_re.materia_pend2.options.add(o);
	}
<?php } ?>
			document.forms.alumno_re.materia_pend2.disabled = false;
	}
function ComponerMaterias2(mat) {
	document.forms.alumno_re.grado_mat_pend2.disabled = true;
		for(var i=document.forms.alumno_re.materia_pend2.options.length-1; i>0; i--){
			document.forms.alumno_re.materia_pend2.remove(i);
		}
	SeleccionarMaterias2(mat);
	document.forms.alumno_re.grado_mat_pend2.disabled = false;
}

function verifyInput(_selList,_textBox,pos) {
	document.getElementById('cedula').readOnly = false;
	var SI = eval(_selList+".selectedIndex");
	var SV = eval(_selList+".options[SI].value");
	eval(_textBox+".value = SV");
	var a = eval(_selList+".options.selectedIndex=0");
	if (pos=='0'){
		document.buscador.cedula.focus();
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">ESTUDIANTE REGULAR</h2></blockquote>
		<fieldset>
		<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
			<form action=inscripcion_regular.php method=GET name='buscador'>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr align=center>
					<td width=50% align=center>C&eacute;dula: <select name='Nac_e' onchange="verifyInput('document.buscador.Nac_e','document.buscador.cedula','0')"><option></option><option value='V-'>V-</option><option value='E-'>E-</option></select><input name='cedula' id='cedula' onKeyUp='comprobar_a(this.value)' onKeyPress='return acceptNum(event)' size=8 maxlength=10 readonly>
					<input class=button type=submit value=Buscar><br><span id='comprobar_mensaje_a'></span></td>
				</tr>
			</table>
			</form>
		</fieldset>
		

<div class="post">
<span></span></div>

<?php if($sql && $sql_r){
echo "
<label><font color=#FF0000>(*) Campos obligatorios</font></label>
	<fieldset>
	<legend align=left><b><font size=2>ESTUDIANTE</font></b></legend>
		<form action=resp_ir.php method=post name=alumno_re id=alumno_re>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=50%>Per&iacute;odo que curs&oacute; / Per&iacute;odo a cursar: </td><td>$row[0] / "; if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2"; } echo "</td>
				<input type=hidden name='periodo' value='"; if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2"; } echo "'>
			</tr>
			<tr>
				<td>C&eacute;dula: </td><td>$row[1]</td>
				<input name=cedula_a type=hidden value='$row[1]'>
			</tr>
			<tr>
				<td>Nombres: </td><td>$row[2]</td>
			</tr>
			<tr>	
				<td>Apellidos: </td><td>$row[3]</td>
			</tr>
			<tr>
				<td>Lugar de Nac.: </td><td>$row[4]</td>
			</tr>
			<tr>	
				<td>Fecha de Nac.: </td><td>$row[5]</td>
			</tr>
			<tr>	
				<td>Edad: </td><td>$edad_a</td>
			</tr>
			<tr>
				<td>Repite </td><td>$row[6]</td>
			</tr>
			<tr>	
				<td>Grado </td><td>$row[7]</td>
			</tr>
			<tr>	
				<td>Secci&oacute;n </td><td>$row[8]</td>
			</tr>
			<tr>
				<td><label style='color: #FF0000'>*</label> Repite: </td><td><input type='radio' name='repite' id='repite' value='Si'>Si <input type='radio' name='repite' id='repite2' value='No'>No
			</tr>
			<tr>
				<td>Materia pendiente vista (materia / a&ntilde;o)</td>
				<td>$mat_pend[0], $mat_pend[1]<br>$mat_pend2[0], $mat_pend2[1]</td>
			</tr>
			<tr>
				<td>Materia pendiente: </td>
				<td><select name=grado_mat_pend onChange='ComponerMaterias(this.options[this.selectedIndex].value)'>
											<option>Grado</option>
											<option value='1er'>1er A&ntilde;o</option>
											<option value='2do'>2do A&ntilde;o</option>
											<option value='3er'>3er A&ntilde;o</option></select>
									<select name=materia_pend><option value='0'>Materia 1</option></select><br>
					<select name=grado_mat_pend2 onChange='ComponerMaterias2(this.options[this.selectedIndex].value)'>
											<option>Grado</option>
											<option value='1er'>1er A&ntilde;o</option>
											<option value='2do'>2do A&ntilde;o</option>
											<option value='3er'>3er A&ntilde;o</option></select>
									<select name=materia_pend2><option value='0'>Materia 2</option></select></td>
			</tr>
			<tr>
				<td><label style='color: #FF0000'>*</label> Grado a cursar / Secci&oacute;n </td><td><select name='grado' id='grado' onChange='materias(this.value)'><option></option>
																	<option value='1er'>1er A&ntilde;o</option>
																	<option value='2do'>2do A&ntilde;o</option>
																	<option value='3er'>3er A&ntilde;o</option></select> / 
															<select name='seccion' id='seccion'><option></option>
																	<option>A</option>
																	<option>B</option></select></td>
			</tr>
			</table>
					<table id=materias_s style='display: none;' border=0 width=100%>
						<tr>
							<td width=58%><b>Materias a cursar: </b></td>
							<td>
								<input type=checkbox name='materia[]' value=11 id=p>Castellano&nbsp;<input type=checkbox name='materia[]' value=21 id=p>Ingles<br>
								<input type=checkbox name='materia[]' value=31 id=p>Matematica&nbsp;<input type=checkbox name='materia[]' value=41 id=p>Est. Nat<br>
								<input type=checkbox name='materia[]' value=51 id=p>Hist. Vzla&nbsp;<input type=checkbox name='materia[]' value=61 id=p>Educ. Fam.<br>
								<input type=checkbox name='materia[]' value=71 id=p>Geografia Gen.&nbsp;<input type=checkbox name='materia[]' value=81 id=p>Educ. Artistica<br>
								<input type=checkbox name='materia[]' value=91 id=p>Educ. Fisica&nbsp;<input type=checkbox name='materia[]' value=101 id=p>Dibujo<br>
								<input type=checkbox name='materia[]' value=111 id=p>Comercio<br>
								<input class=button type='button' value='Marcar todos' onClick='this.value=check(this.form.p)'></td>
						</tr>
					</table>

					<table id=materias_o style='display: none;' border=0 width=100%>
						<tr>
							<td width=56%><b>Materias a cursar: </b></td>
							<td>
								<input type=checkbox name='materia[]' value=12 id=s>Castellano&nbsp;<input type=checkbox name='materia[]' value=22 id=s>Ingles<br>
								<input type=checkbox name='materia[]' value=32 id=s>Matematica&nbsp;<input type=checkbox name='materia[]' value=42 id=s>Biologia<br>
								<input type=checkbox name='materia[]' value=52 id=s>Hist. Vzla&nbsp;<input type=checkbox name='materia[]' value=62 id=s>Hist. Universal<br>
								<input type=checkbox name='materia[]' value=72 id=s>Educ. Artistica&nbsp;<input type=checkbox name='materia[]' value=82 id=s>Salud<br>
								<input type=checkbox name='materia[]' value=92 id=s>Educ. Fisica&nbsp;&nbsp;&nbsp;<input type=checkbox name='materia[]' value=102 id=s>Dibujo&nbsp;<input type=checkbox name='materia[]' value=112 id=s>Comercio<br>
								<input class=button type='button' value='Marcar todos' onClick='this.value=check(this.form.s)'></td>
						</tr>
					</table>

					<table id=materias_n style='display: none;' border=0 width=100%>
						<tr>
							<td width=57%><b>Materias a cursar: </b></td>
							<td>
								<input type=checkbox name='materia[]' value=13 id=t>Castellano&nbsp;<input type=checkbox name='materia[]' value=23 id=t>Ingles<br>
								<input type=checkbox name='materia[]' value=33 id=t>Matematica&nbsp;<input type=checkbox name='materia[]' value=43 id=t>Cs Biologicas<br>
								<input type=checkbox name='materia[]' value=53 id=t>Fisica&nbsp;<input type=checkbox name='materia[]' value=63 id=t>Quimica<br>
								<input type=checkbox name='materia[]' value=73 id=t>Catedra Boliv.&nbsp;<input type=checkbox name='materia[]' value=83 id=t>Geografia<br>
								<input type=checkbox name='materia[]' value=93 id=t>Educ. Fisica&nbsp;<input type=checkbox name='materia[]' value=103 id=t>Dibujo&nbsp;<input type=checkbox name='materia[]' value=113 id=t>Comercio<br>
								<input class=button type='button' value='Marcar todos' onClick='this.value=check(this.form.t)'></td>
						</tr>
					</table>
	</fieldset>

<div class=post>
<span></span></div>
	
	<fieldset>
	<legend align=left><b><font size=2>REPRESENTANTE</font></b></legend>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=50%>C&eacute;dula: </td><td>$row_r[0]</td>
			</tr>
			<tr>
				<td>Nombres: </td><td>$row_r[1]</td>
			</tr>
			<tr>	
				<td>Apellidos: </td><td>$row_r[2]</td>
			</tr>
		</table>
	</fieldset>

<div class=post>
<span></span></div>

	<fieldset>
	<legend align=left><b><font size=2>RECAUDOS ENTREGADOS</font></b></legend>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=33%><input type=checkbox name=par_nac> Partida de Nac.</td>
				<td width=33%><input type=checkbox name=fotos_r id=fotos_r onClick='DeshabilitaSelect();'> Fotos Rep. <select name=fot_r id=fot_r disabled><option></option><option>1</option><option>2</option></select></td>
				<td width=33%><input type=checkbox name=fotos_a id=fotos_a onClick='DeshabilitaSelect();'> Fotos Est. <select name=fot_a id=fot_a disabled><option></option><option>1</option><option>2</option><option>3</option><option>4</option></select></td>
			</tr>
			<tr>
				<td><input type=checkbox name=c_ced_a> Fotocopia C.I. Est.</td>
				<td><input type=checkbox name=c_ced_r> Fotocopia C.I. Rep.</td>
			</tr>
		</table>
		
	</fieldset>

<div class=post>
<span></span></div>

<div id=botonera align=center>
	<input class=button type=submit value=Guardar name=submit>
	<input class=button type=submit value=Cancelar onClick=location='index.php'>
</div>";
} ?>

</form>
</div>
<div class="post_b">
<span></span></div>
</div>

</div>

<div class="post">
<div class="post_h">

</div>

</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
